#include <iostream>
#include <string>
using namespace std;

const int kMaxN = 120;

int n;
string s[kMaxN];
int vis[kMaxN][kMaxN] = {0}, flag = 0;
int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

bool Check(int x, int y, char c) {
  return x >= 0 && x < n && y >= 0 && y < n && vis[x][y] != flag && s[x][y] == c;
}

void DFS(int x, int y, char c) {
  vis[x][y] = flag;
  for (int k = 0; k < 4; k++) {
    if (Check(x + dir[k][0], y + dir[k][1], c)) {
      DFS(x + dir[k][0], y + dir[k][1], c);
    }
  }
}

int Count() {
  int ans = 0;

  flag++;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (vis[i][j] != flag) {
        DFS(i, j, s[i][j]);
        ans++;
      }
    }
  }
  return ans;
}

int main() {
  freopen("cowart.in", "r", stdin);
  freopen("cowart.out", "w", stdout);

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  cout << Count() << " ";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (s[i][j] == 'G') {
        s[i][j] = 'R';
      }
    }
  }
  cout << Count() << "\n";
  return 0;
}